<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><{:C('web_site_name')}></title>
    <link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/main.css"/>

    <script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/jquery.js"></script>
    <script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/lib.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/layer.min.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/admin.js"></script>
</head>
<body>
<div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i>首页<span class="crumb-step">&gt;</span><span class="crumb-name">后台用户管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="#" method="post">
                    <table class="search-tab">
                        <tr>
                           
                            <th width="70">用户名:</th>
                            <td><input class="common-text" placeholder="用户名" name="username" value="" id="" type="text"></td>
                            <th width="70">昵称:</th>
                            <td><input class="common-text" placeholder="昵称" name="nick" value="" id="" type="text"></td>	
                           	<th width="70">所属组:</th>
                           	<td>
                             <select name="gid">
                             <option value="">请选择</option>
							<?php 
								if(isset($group) && $group){
									foreach($group as $k_=>$v_){
					
								?>
				<option value="<?php echo $v_['id'];?>" ><?php echo $v_['rolename'];?></option>
						<?php 
								}	
									}
						?>
	</select>
                                </td>
                            <td><input class="btn btn-primary btn2" name="sub" value="查询" type="button" onclick="search()"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="javascript:void(0)" onclick="add()"><i class="icon-font"></i>新增后台用户</a>
                    </div>
                </div>
                 <div class="list-page" id="page_string"> 2 条 1/1 页</div>
                <div class="result-content">
                    <table class="result-tab" width="100%" >
                        <tr>
                            <th>编号<i class="sort" field="id" orderby = "desc"  style="cursor:pointer"><img src="<?php echo APP_TMPL_PATH ;  ?>/static/images/px.gif"></i></th>
                            <th>用户名</th>
                            <th>昵称</th>
                            <th>添加日期 <i class="sort" field="addtime" orderby = "desc"  style="cursor:pointer"><img src="<?php echo APP_TMPL_PATH ;  ?>/static/images/px.gif"></i></th>
                            <th>状态</th>
                            <th>用户组</th>
                            <th>是否是管理员</th>
                       
                            <th>操作</th>
                        </tr>
                      <tbody id="result_"></tbody>
                        
                    </table>
                    
                    	
                    <div class="list-page" id="page_string"> 2 条 1/1 页</div>
                </div>
            </form>
        </div>
</body>
</html>
<script>
var loadding_0  ;
var page = 1 ;
var field = "id" ; //  哪个字段排序
var orderby = "desc" ; //升序还是降序
$(function () {
	common_request();
});
function common_request(){
	var url="<?php echo U("sysadmin/index");?>&inajax=1";
	var data_ = {
		'page':page,
		'time':<?php echo time();?>,
		'action':'ajax_data' , 
		'username':$("input[name='username']").val() , 
		'gid':$("select[name='gid']").val() , 
        'nick':$("input[name='nick']").val() , 
		'field':field , 
		'orderby':orderby
	} ;
    $.ax(
        url,data_,true,"POST","JSON",function(msg){
        var shtml = '' ;
        var list = msg.resultinfo.list;
        if(msg.resultcode != 1 ){
            layer.msg(msg.resultinfo.errmsg);
            return false ;
        }else{
            for(var i in list){
                shtml+='<tr>';
                shtml+= '<td>'+list[i].id+'</td>' ;
                shtml+='<td>'+list[i]['username']+'</td>';
                shtml+='<td>'+list[i]['nick']+'</td>';
                shtml+='<td >'+list[i]['addtime']+'</td>';
                shtml+='<td>'+list[i]['status']+'</td>';
                shtml+='<td>'+list[i]['gid']+'</td>';
                shtml+='<td>'+list[i]['super_admin']+'</td>';
                shtml+='<td><a href="<?php echo U('sysadmin/edit');?>&id='+list[i].id+'" class="tablelink">设置权限</a>&nbsp;&nbsp;  <a href="javascript:void(0)" onclick="passwd('+list[i].id+',this)" class="tablelink">密码修改</a>&nbsp;&nbsp;</td>';
                shtml+='</tr>';
            }  
        }
        $("#result_").html(shtml);
        $(".list-page").html(msg.resultinfo.obj);
        layer.close(loadding_0);
        },function(e){
            layer.msg('服务器繁忙请稍后');
            return false ;   
        },function(f){
            loadding_0 = layer.load('数据正在加载中1。。。。。。'); 
        }
    );
}
function ajax_data(p){
	page = p  ; 
	common_request();
}
function search(){
	page = 1 ;
	common_request();
}
//添加后台用户
function add(){
	$.layer({
	    type: 2,
	    shadeClose: true,
	    title: "添加后台用户",
	    closeBtn: [0, true],
	    shade: [0.8, '#000'],
	    border: [1],
	    offset: ['20px',''],
	    area: ['720px','460px'],
	    iframe: {src: "<?php echo U("sysadmin/add");?>&showpage=1"}
	}); 
}

$(".result-tab i.sort").each(function(){
	$(this).click(function(){
		field = $(this).attr("field");
		orderby = $(this).attr("orderby");
		$(this).attr("orderby" , ((orderby == 'asc' )?'desc':'asc') )  ;
		page = 1 ;  
		common_request() ; 
	});
});
function passwd(id , o ){
	$.layer({
	    type: 2,
	    shadeClose: true,
	    title: "修改管理员密码",
	    closeBtn: [0, true],
	    shade: [0.8, '#000'],
	    border: [1],
	    offset: ['20px',''],
	    area: ['720px','460px'],
	    iframe: {src: "<?php echo U("sysadmin/passwd");?>&showpage=1&id="+id}
	}); 
}
</script> 

